/*!
 * @author  Vladimir Kerimov
 * @file    dataset.h
 * @version 1.0
 * @brief   Data set
 * @date    2013
 */

/*
 *    ______   __
 *   /  ___/  /__/   __  ___      _____        _____     __    __     _____        __  ___      _____     __  ___
 *  |  |___    __   /  |/   \    / __  \      /  _  \   |  |  |  |   /  _  \      |  |/   \    /  _  \   |  |/   \
 *   \___  \  /  |  |   __   |  | /  __/     |  / \  |  |  |  |  |  |  / \  |     |   __   |  |  / \  |  |   __   |
 *  ____/  /  |  |  |  /  \  |  |   /___     |  \_/  |  |   \_|  |  |  \_/  |     |  /  \  |  |  \_/  |  |  /  \  |
 * /______/   |__/  |__|  |__/   \_____/      \___   |   \___/|__|   \___/|_|     |__|  |__|   \_____/   |__|  |__|
 *                                                |  |
 *                                                |__/
 *
 */

#pragma once

#include <qua/api.h>
#include <qua/lazy.h>

namespace qua
{
    class on;
    class text;

    class QUAZAR_API dataset
    {
    public:
        class row;
        class column;
        class selection;
        class sorting;

        dataset( text const& source );

        dataset& select( selection const& fields );
        dataset& join( dataset::column const& link, on const& condition );
        dataset& where( on const& condition );
        dataset& order_by( sorting const& order );
        dataset& limit( size_t value );
        dataset& offset( size_t value );

        column operator [] ( text const& name ) const;
        row operator [] ( int index ) const;

    private:
        class data;

        lazy<data> m_data;
    };

    class QUAZAR_API on
    {
    public:
        on( dataset::column );

        on operator == ( on const& other ) const;
        on operator != ( on const& other ) const;
        on operator <= ( on const& other ) const;
        on operator >= ( on const& other ) const;
        on operator <  ( on const& other ) const;
        on operator >  ( on const& other ) const;

        on operator && ( on const& other ) const;
        on operator || ( on const& other ) const;

        on operator ! () const;

        operator bool () const;

    private:
        class data;

        lazy<data> m_data;
    };
}
